package horncomb.bpm.process.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;

import horncomb.bpm.process.core.entity.TokenEntity;

/**
 * @author Daniel
 */
@Entity
@MappedSuperclass
@Table(name = "BPM_TOKEN")
public class DefaultTokenEntity implements TokenEntity {
	private static final long serialVersionUID = 1159165972282957953L;
	/** token唯一标识 */
	private String id;
	/** token名称 */
	private String name;
	// private String prestateId;
	/** 状态Id */
	private String stateId;
	/** 状态进入时间 */
	private Date enteredDate;

	/** 业务定义Id */
	private String bizDefinitionId;
	/** 业务实体Id */
	private String bizEntityId;

	public String getType() {
		return "TK";
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TokenEntity other = (TokenEntity) obj;
		if (id == null) {
			if (other.getId() != null)
				return false;
		} else if (!id.equals(other.getId()))
			return false;
		return true;
	}

	/**
	 * @return the processDefinitionId
	 */
	@Column(name = "PROC_INST_")
	public String getProcessInstanceId() {
		return this.getId();
	}

	/**
	 * @param processDefinitionId
	 *            the processDefinitionId to set
	 */
	public void setProcessInstanceId(String processInstanceId) {
		// do nothing
	}

	/**
	 * @return the id
	 */
	@Id
	@Column(name = "ID_")
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	@Column(name = "NAME_")
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the stateId
	 */
	@Column(name = "STATE_")
	public String getStateId() {
		return stateId;
	}

	/**
	 * @param stateId
	 *            the stateId to set
	 */
	public void setStateId(String state) {
		this.stateId = state;
	}

	/**
	 * @return the enteredDate
	 */
	@Column(name = "ENTER_")
	public Date getEnteredDate() {
		return enteredDate;
	}

	/**
	 * @param enteredDate
	 *            the enteredDate to set
	 */
	public void setEnteredDate(Date enteredDate) {
		this.enteredDate = enteredDate;
	}

	// /**
	// * @return the prestateId
	// */
	// public String getPrestateId() {
	// return prestateId;
	// }
	//
	// /**
	// * @param prestateId
	// * the prestateId to set
	// */
	// public void setPrestateId(String prestateId) {
	// this.prestateId = prestateId;
	// }

	/**
	 * @return the bizDefinitionId
	 */
	@Column(name = "BIZ_DEF_")
	public String getBizDefinitionId() {
		return bizDefinitionId;
	}

	/**
	 * @param bizDefinitionId
	 *            the bizDefinitionId to set
	 */
	public void setBizDefinitionId(String bizDefinitionId) {
		this.bizDefinitionId = bizDefinitionId;
	}

	/**
	 * @return the bizEntityId
	 */
	@Column(name = "BIZ_ENTITY_")
	public String getBizEntityId() {
		return bizEntityId;
	}

	/**
	 * @param bizEntityId
	 *            the bizEntityId to set
	 */
	public void setBizEntityId(String bizEntityId) {
		this.bizEntityId = bizEntityId;
	}
}
